package cn.zyg.ymcc.feign;

import cn.zyg.ymcc.domain.Login;
import cn.zyg.ymcc.enums.GlobalExceptionCode;
import cn.zyg.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class LoginServiceFallbackFactory implements FallbackFactory<LoginService> {
    @Override
    public LoginService create(Throwable throwable) {
        throwable.printStackTrace();
        log.error("service-uaa服务发生异常，触发熔断，熔断类为LoginService",throwable.getMessage());
        return new LoginService() {
            @Override
            public JSONResult saveOrUpdate(Login login) {
                return JSONResult.error(GlobalExceptionCode.ERROR);
            }
        };
    }
}
